// SPU管理接口
// 统一管理用户相关接口
import http from '@/utils/request'

import type { skuResponseDataType, skuInfoData } from './type.ts'

// 通过枚举统一管理接口
enum API {
  SKULIST_URL = '/admin/product/list',
  CANCELSALE_URL = '/admin/product/cancelSale',
  ONSALE_URL = '/admin/product/onSale',
  SKUINFO_URL = '/admin/product/getSkuInfo',
  DELETESKU_URL = '/admin/product/deleteSku',
}

// 获取sku表格数据
export const getSkuListAPI = (page: number, limit: number) => http.get<any, skuResponseDataType>(API.SKULIST_URL + `/${page}/${limit}`)

// 商品上架
export const onSaleAPI = (id: number | string) => http.get<any, any>(API.ONSALE_URL + `/${id}`)

// 商品下架
export const cancelSaleAPI = (id: number | string) => http.get<any, any>(API.CANCELSALE_URL + `/${id}`)

// 商品详情
export const getSkuInfoAPI = (id: number | string) => http.get<any, skuInfoData>(API.SKUINFO_URL + `/${id}`)

// 删除商品
export const deleteSkuAPI = (id: number | string) => http.delete<any, any>(API.DELETESKU_URL + `/${id}`)